# 购物车已存在的商品再次添加，商品数量加一
# 商品的名称不存在，商品添加的数量超过商品的库存

class Cart():
    def __init__(self):
        self.cart = [{"name":"金典牛奶","price":5.0,"count":10}] #购物车列表
    #添加商品到购物车
    def addCart(self,name,price,count):
        if name == None or name.strip() == "":
            return {"status":400,"msg":"商品不存在"}
        else:
            if count > 100:
                return {"status":500,"msg":"商品的库存不足"}
            else:
                # 构造商品字典
                product = {"name":name,"price":price,"count":count}
                for item in self.cart:
                    if item["name"] == name:  # 说明商品已存在
                        item["count"] = item["count"] + count
                        return {"status": 201, "msg": "商品存在 数量增加"}
                # 添加商品到购物车
                self.cart.append(product)
                return {"status":200,"msg":"添加成功"}